Skip to content

fix(aio): avoid retrying successfully submitted batches - #2417

Open
Alex Castillo González (pcbeingused333) wants to merge 1 commit into
confluentinc:masterfrom
pcbeingused333:fix/c2044-aio-batch-requeue
Open

Alex Castillo González (pcbeingused333) wants to merge 1 commit into
confluentinc:masterfrom
pcbeingused333:fix/c2044-aio-batch-requeue

Conversation

@pcbeingused333

Copy link
Copy Markdown

What

A flush can submit one topic/partition batch and then fail on a later one. The exception handler in flush_buffer puts every batch back in the buffer, so the next flush produces the earlier messages again, even if they were already delivered or their delivery callbacks are still pending.

One way to hit it: produce_batch raises TypeError when a message value is not bytes or str. With a valid message for partition 0 and value=123 for partition 1, each flush fails on partition 1 and resubmits partition 0. The automatic buffer timeout flush can repeat this without the application calling anything.

This change removes the successfully submitted prefix from the retry list on failure. The failed batch and the unattempted batches stay buffered, so the existing retry and future failure behavior does not change.

Checklist

  • Contains customer facing changes? Yes: messages from batches that were already submitted are no longer produced again after a later batch fails in the same flush.
  • Did you add sufficient unit test and/or integration test coverage for this PR?

References

JIRA: none, no existing issue. Added a changelog entry.

Test & Review

  • New regression in tests/test_producer_batch_processor.py: full and topic-selective flushes, with delivered and pending callbacks. It checks the preserved futures and the calls made by the next flush. No broker needed.
  • All four regression subtests fail on master because the buffer still holds the successful batch, and pass with the change.
  • tests/test_producer_batch_processor.py and tests/test_kafka_batch_executor.py: 25 passed, 4 subtests passed.
  • With a real Producer and no broker, the example above over three flushes submits the partition 0 message 3 times on master and once with the change.
  • black, isort and flake8 pass on the touched Python files.

AI assistance: this change and its tests were prepared with Codex and reviewed with Claude.

@confluent-cla-assistant

Copy link
Copy Markdown

Please sign the Contributor License Agreement here before this PR can be approved.
❌ pcbeingused333
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

@Ankith-Confluent Ankith L (Ankith-Confluent) added the status:waiting-for-interest Valid idea, not on roadmap — waiting for community interest or demand label Nov 18, 2026
@pcbeingused333

Copy link
Copy Markdown
Author

Gentle ping: this is ready for review whenever someone has a moment. Happy to rebase or adjust anything if needed. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:waiting-for-interest Valid idea, not on roadmap — waiting for community interest or demand

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants